<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"example.com","root":"/","images":"/images","scheme":"Muse","version":"8.6.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>
<meta property="og:type" content="website">
<meta property="og:title" content="风轻云淡">
<meta property="og:url" content="http://example.com/index.html">
<meta property="og:site_name" content="风轻云淡">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="WQQ">
<meta property="article:tag" content="风">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://example.com/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":true,"isPost":false,"lang":"zh-CN","comments":"","permalink":"","path":"index.html","title":""}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>风轻云淡</title>
  




  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
	<!-- 页面点击小红心 -->
	<script type="text/javascript" src="/js/src/clicklove.js"></script>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">风轻云淡</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">清风吹拂，白云淡淡</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-首页"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li>
        <li class="menu-item menu-item-关于"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li>
        <li class="menu-item menu-item-标签"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li>
        <li class="menu-item menu-item-分类"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
  </ul>
</nav>




</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-overview-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-overview">
            <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="WQQ"
      src="/images/aaa.jpg">
  <p class="site-author-name" itemprop="name">WQQ</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
          <span class="site-state-item-count">14</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="https://gitee.com/wqqszz" title="GitHub → https:&#x2F;&#x2F;gitee.com&#x2F;wqqszz" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="QQ:1640611853@qq.com" title="E-Mail → QQ:1640611853@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



          </div>
        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner index posts-expand">

    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/10/03/LINUX%E6%9C%8D%E5%8A%A1%E5%99%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/10/03/LINUX%E6%9C%8D%E5%8A%A1%E5%99%A8/" class="post-title-link" itemprop="url">LINUX服务器</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-10-03 22:58:55" itemprop="dateCreated datePublished" datetime="2022-10-03T22:58:55+08:00">2022-10-03</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2022-10-04 21:16:43" itemprop="dateModified" datetime="2022-10-04T21:16:43+08:00">2022-10-04</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h2 id="centos7安装"><a href="#centos7安装" class="headerlink" title="centos7安装"></a>centos7安装</h2><h3 id="《《《《《安装Jdk》》》》》"><a href="#《《《《《安装Jdk》》》》》" class="headerlink" title="《《《《《安装Jdk》》》》》"></a><strong>《《《《《安装Jdk》》》》》</strong></h3><p>1，创建jdk安装目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost ~]# mkdir -p /usr/local/src/jdk</span><br></pre></td></tr></table></figure>

<p>2，下载jdk包</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost jdk]# wget --no-check-certificate --no-cookies --header &quot;Cookie: oraclelicense=accept-securebackup-cookie&quot;  http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz</span><br></pre></td></tr></table></figure>

<p>3，解压jdk包</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost jdk]# tar -zxvf jdk-8u212-linux-x64.tar.gz</span><br></pre></td></tr></table></figure>

<p>4，自定义文件夹名称</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost jdk]#  mv jdk1.8.0_131  jdk1.8</span><br></pre></td></tr></table></figure>

<p>5，配置环境变量</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost jdk]# vi /etc/profile  (可以看到这个文件的内容，profile文件有点类似于windows系统里面的环境变量的配置）</span><br><span class="line">shift + g 定位到最后一行</span><br><span class="line">需要配置的内容：</span><br><span class="line">export JAVA_HOME=/usr/local/src/jdk/jdk1.8</span><br><span class="line">export PATH=$PATH:$JAVA_HOME/bin</span><br></pre></td></tr></table></figure>

<p>6，退出文件，保存</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">按Esc键   输入:wq   保存并退出</span><br></pre></td></tr></table></figure>

<p>7，让配置文件生效</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure>

<p>8，查看是否配置成功</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">命令：java -version</span><br></pre></td></tr></table></figure>



<h3 id="《《《《《安装tomcat-》》》》"><a href="#《《《《《安装tomcat-》》》》" class="headerlink" title="《《《《《安装tomcat 》》》》"></a><strong>《《《《《安装tomcat 》》》》</strong></h3><p>1 ,下载tomcat </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">wget https://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.5.82/bin/apache-tomcat-8.5.82.tar.gz</span><br><span class="line">(可以更换其他版本)</span><br></pre></td></tr></table></figure>

<p>2, 创建tomcat存放目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p  /usr/local/src/tomcat</span><br></pre></td></tr></table></figure>

<p>2，解压</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd /tomcat</span><br><span class="line">tar -zxvf apache-tomcat-8.5.82.tar.gz</span><br><span class="line">mv apache-tomcat-8.5.82 tomcat8</span><br></pre></td></tr></table></figure>

<p>3,配置环境变量</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">vi /etc/profile</span><br><span class="line"><span class="meta">#</span><span class="bash"> <span class="built_in">shift</span> + g 文件末尾，追加如下</span></span><br><span class="line">export TOMCAT_HOME=/usr/local/src/tomcat/tomcat8</span><br><span class="line">export PATH=$PATH:$TOMCAT_HOME/bin</span><br></pre></td></tr></table></figure>

<p>4,刷新配置，使配置生效</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure>

<p>5,配置开机自启</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">进入到 cd /etc/init.d</span><br><span class="line">创建tomcat    vi tomcat</span><br><span class="line">.将以下代码复制到创建的 tomcat 配置文件中：	</span><br><span class="line"><span class="meta">#</span><span class="bash">!/bin/bash</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> description: Tomcat Start Stop Restart</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> processname: tomcat</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> chkconfig: 2345 20 80</span></span><br><span class="line"><span class="meta">#</span><span class="bash">idea - tomcat config start</span> </span><br><span class="line"><span class="meta">#</span><span class="bash">!/bin/bash</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> description: Tomcat Start Stop Restart</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> processname: tomcat</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> chkconfig: 2345 20 80</span></span><br><span class="line">JAVA_HOME=/usr/local/src/jdk/jdk1.8</span><br><span class="line">export JAVA_HOME</span><br><span class="line">PATH=$JAVA_HOME/bin:$PATH</span><br><span class="line">export PATH</span><br><span class="line">CATALINA_HOME=/usr/local/src/tomcat/tomcat8</span><br><span class="line">case $1 in  </span><br><span class="line">start)</span><br><span class="line">sh $CATALINA_HOME/bin/startup.sh ;;</span><br><span class="line">stop)</span><br><span class="line">sh $CATALINA_HOME/bin/shutdown.sh</span><br><span class="line">;;</span><br><span class="line">restart)</span><br><span class="line">sh $CATALINA_HOME/bin/shutdown.sh</span><br><span class="line">sh $CATALINA_HOME/bin/startup.sh</span><br><span class="line">;;</span><br><span class="line">esac</span><br><span class="line">exit 0</span><br><span class="line"><span class="meta">#</span><span class="bash">chmod 755 tomcat</span></span><br><span class="line"><span class="meta">#</span><span class="bash">chkconfig --add tomcat</span></span><br><span class="line"><span class="meta">#</span><span class="bash">chkconfig --level 2345 tomcat on</span></span><br></pre></td></tr></table></figure>


<p>6 ,为 tomcat 分配可执行权限</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chomd 777 tomcat</span><br></pre></td></tr></table></figure>
<p>7, 添加 tomcat 为系统服务：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chkconfig --add tomcat</span><br></pre></td></tr></table></figure>

<p>8 ,输入命令查看是否添加成功： chkconfig –list</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">2，3，4，5都是开代表跟随系统而启动</span><br></pre></td></tr></table></figure>
<p>9 启动 tomcat命令：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service tomcat start</span><br></pre></td></tr></table></figure>


<p>​    </p>
<h3 id="《《《《NGINX安装》》》》"><a href="#《《《《NGINX安装》》》》" class="headerlink" title="《《《《NGINX安装》》》》"></a><strong>《《《《NGINX安装》》》》</strong></h3><ol>
<li>环境准备<br>#gcc安装 ，为了编译Nginx源代码，我们需要标准的GCC编译器<br>yum -y install gcc-c++<br>#pcre安装，由于Nginx的一些模块还需要依赖其他第三方库pcre库，zlib库，openssl库（支持ssl模块）所以在编译Nginx源代码前还需要安装这些这些库。<br>yum  -y install  pcre pcre-devel<br>#zlib安装<br>yum -y install zlib zlib-devel<br>#OpenSSL安装<br>yum -y install openssl openssl-devel</li>
</ol>
<p>  在进行上面的安装之前，最好使用下面的命令看下这些软件包是否已经安装过了。<br>  yum list installed | grep ***</p>
<p>2, 创建nginx安装目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p /usr/local/nginx</span><br></pre></td></tr></table></figure>

<p>3,进入安装目录。下载安装包</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/local/nginx</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wget http://nginx.org/download/nginx-1.13.7.tar.gz (如需要可更改指定版本)</span><br></pre></td></tr></table></figure>

<p>4，解压</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -zxvf nginx-1.13.7.tar.gz</span><br></pre></td></tr></table></figure>

<p>5,进入解压后的目录。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">cd nginx-1.13.7</span><br><span class="line"><span class="meta">#</span><span class="bash">进入解压后的目录</span></span><br><span class="line"><span class="meta">#</span><span class="bash">配置安装路径等其他配置，默认安装目录是/usr/<span class="built_in">local</span>/nginx</span></span><br><span class="line">./configure</span><br><span class="line"><span class="meta">#</span><span class="bash">编译安装nginx</span></span><br><span class="line">make</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>

<p>6,Nginx的安装就已经结束了。其实在上面的configure命令执行时我们是可以配置很多参数的，上面的安装中我们全部使用的是Nginx的默认配置</p>
<p>7 启动nginx </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/local/nginx/sbin</span><br><span class="line">./nginx  #启动nginx</span><br><span class="line"></span><br><span class="line">默认端口80 </span><br><span class="line">访问地址：http://ip:80</span><br></pre></td></tr></table></figure>

<p>常用命令有：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">./nginx -t # 验证配置文件是否能正常启动</span><br><span class="line">./nginx #启动nginx</span><br><span class="line">./nginx -s quit #正常停止</span><br><span class="line">./nginx -s stop #快速停止</span><br><span class="line">./nginx -s reload #重新加载</span><br><span class="line">./nginx -v #查看版本信息</span><br></pre></td></tr></table></figure>


<p> 安装阶段已验证，卸载阶段未验证<br> 8, nginx卸载</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">命令 ps -ef | grep nginx检查一下nginx服务是否在运行。</span><br><span class="line">ps -ef | grep nginx</span><br></pre></td></tr></table></figure>

<p>9 , 停止服务</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost ~] cd /usr/local/nginx/sbin</span><br><span class="line">[root@localhost sbin] ./nginx -s stop #快速停止</span><br><span class="line">[root@localhost sbin]  netstat -lntp</span><br></pre></td></tr></table></figure>

<p>10, 查找删除nginx相关文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">查看Nginx相关文件：</span><br><span class="line">	whereis nginx</span><br><span class="line">find查找相关文件</span><br><span class="line">	find / -name nginx</span><br><span class="line">依次删除find查找到的所有目录：rm -rf /usr/local/nginx/sbin/nginx</span><br></pre></td></tr></table></figure>

<p>11，再使用yum清理</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum remove nginx</span><br></pre></td></tr></table></figure>

<p>​<br>12，最后设置开机自动启动：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">在/etc/rc.d/rc.local中添加nginx启动命令行：</span><br><span class="line">/usr/local/nginx/sbin/nginx</span><br><span class="line">赋权：</span><br><span class="line">chmod +x /etc/rc.d/rc.local</span><br></pre></td></tr></table></figure>




<h3 id="《《《《安装msql》》》》"><a href="#《《《《安装msql》》》》" class="headerlink" title="《《《《安装msql》》》》"></a><strong>《《《《安装msql》》》》</strong></h3><p>Centos7快速安装Mysql<br>1, 下载 </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm</span><br></pre></td></tr></table></figure>

<p>2,</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install mysql57-community-release-el7-10.noarch.rpm&#x27;</span><br></pre></td></tr></table></figure>


<p>3,重新导入秘钥（执行第四步报如下错Failing package is: mysql-community-client-5.7.39-1.el7.x86_64<br> GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql的时候,先执行如下）</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022</span><br></pre></td></tr></table></figure>
<p>4 安装：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install mysql-community-server	</span><br></pre></td></tr></table></figure>

<p>5 启动：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service mysqld start</span><br></pre></td></tr></table></figure>

<p>6 查看默认的密码: </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">grep &quot;password&quot; /var/log/mysqld.log </span><br></pre></td></tr></table></figure>

<p>7 登录mysql：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysql -uroot -p</span><br></pre></td></tr></table></figure>

<p>8   (设置密码复杂度，0最低级，1中级 2高级)</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">mysql&gt;</span><span class="bash"> <span class="built_in">set</span> global validate_password_policy=0;</span></span><br></pre></td></tr></table></figure>

<p>9  (设置密码长度)</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">mysql&gt;</span><span class="bash"> <span class="built_in">set</span> global validate_password_length=1;</span> </span><br></pre></td></tr></table></figure>



<p>10 (设置后的密码root)</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">mysql&gt;</span><span class="bash"> alter user <span class="string">&#x27;root&#x27;</span>@<span class="string">&#x27;localhost&#x27;</span> IDENTIFIED BY <span class="string">&#x27;新密码&#x27;</span>; (修改新密码)</span></span><br></pre></td></tr></table></figure>



<p>11 显示所有的库</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">mysql&gt;</span><span class="bash"> show databases;</span></span><br></pre></td></tr></table></figure>

<p>12 服务器外连接mysql 时报is not allowed to connect to this mysql server错误时：执行一下四步，</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">① 登录：mysql -uroot -p </span><br><span class="line">② 执行use mysql;</span><br><span class="line">③ 执行update user set host = &#x27;%&#x27; where user =&#x27;root&#x27;;</span><br><span class="line">④ 执行FLUSH PRIVILEGES;（注意：这一步刷新MySQL的权限相关表，刷信后才能生效）</span><br></pre></td></tr></table></figure>


<p>卸载Mysql<br>​<br>1  首先查看mysql有哪些文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -qa|grep -i mysql</span><br></pre></td></tr></table></figure>

<p>2 yum remove 文件名</p>
<p>3、查找mysql的配置文件和数据库</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">find / -name mysql</span><br></pre></td></tr></table></figure>
<p>  查找的结果进行执行如下删除操作:<br>  rm -rf /var/lib/mysql</p>
<p>  rm -rf /usr/share/mysql</p>
<p>  rm -rf /etc/selinux/targeted/active/modules/100/mysql</p>
<p>  LINUX 中 mysql 中常用的命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service mysql start </span><br></pre></td></tr></table></figure>
<p>​    </p>
<h3 id="《《《《-搭建FTP文件服务器-》》》》"><a href="#《《《《-搭建FTP文件服务器-》》》》" class="headerlink" title="《《《《 搭建FTP文件服务器 》》》》"></a><strong>《《《《 搭建FTP文件服务器 》》》》</strong></h3><p>1，检查是否已经安装了FTP服务器。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -qa | grep vsftpd</span><br></pre></td></tr></table></figure>

<p>2，若没有安装过，则执行以下命令进行安装。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install vsftpd</span><br></pre></td></tr></table></figure>

<p>安装完毕后：注意vsftpd的默认配置文件路径在 /etc/vsftpd/vsftpd.conf </p>
<p>3，创建虚拟用户。</p>
<p>创建vuser.list文件，当做ftp认证时使用的数据库文件。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">[root@localhost/]#</span><span class="bash">	<span class="built_in">cd</span> /etc/vsftpd/</span></span><br><span class="line"><span class="meta">[root@vsftpd]#</span><span class="bash">	vim vuser.list</span>	</span><br><span class="line">1	wqq</span><br><span class="line">2	123456</span><br><span class="line">3	szz</span><br><span class="line">4	123456</span><br></pre></td></tr></table></figure>

<p>vuser.list编辑的内容：奇数行为账户名，偶数行为密码.</p>
<p>4，对数据库文件进行加密处理,利用db_load命令用哈希算法进行加密处理</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">db_load  -T  -t  hash  -f vuser.list  vuser.db</span><br></pre></td></tr></table></figure>



<p> 5，建立用于支持虚拟用户的PAM文件。</p>
<p>​    在/etc/pam.d/路径下新建一个vsftpd.vu 文件，编辑内容如下</p>
<p>​    查看系统位数：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">查看代码位数，64位或32位</span></span><br><span class="line">getconf  LONG_BIT</span><br></pre></td></tr></table></figure>

<p>​    如果64位：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> db 参数为使用db_load命令生成的账户密码数据库文件的路径，但不用写数据库文件的后缀</span></span><br><span class="line">auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser</span><br><span class="line">account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser</span><br></pre></td></tr></table></figure>

<p>​    如果32位：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> db 参数为使用db_load命令生成的账户密码数据库文件的路径，但不用写数据库文件的后缀</span></span><br><span class="line">auth required pam_userdb.so db=/etc/vsftpd/vuser</span><br><span class="line">account required pam_userdb.so db=/etc/vsftpd/vuser</span><br></pre></td></tr></table></figure>

<p>6，创建ftp用户,</p>
<p>​    指定一个存放上传文件的地方，将 /var/ftp/pub作为FTP服务的根目录，</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">创建一个没有登录权限的用户，并且指定用户登入时的起始目录</span></span><br><span class="line">useradd  ftpuser -d  /var/ftp/pub -s /sbin/nologin</span><br><span class="line"><span class="meta">#</span><span class="bash">修改ftp文件夹权限，指定用户和用户组都为ftpuser</span></span><br><span class="line">chown -R ftpuser.ftpuser /var/ftp/pub</span><br><span class="line"><span class="meta">#</span><span class="bash">设置用户ftpuser 的密码</span></span><br><span class="line">passwd ftpuser</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>7，为虚拟用户设置不同的权限。</p>
<p>①在FTP服务的根目录下，设置FTP虚拟用户的存储目录(当虚拟用户登录后所访问的默认位置)，在/var/ftp/pub目录下，新建ray和stone两个目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@/] cd /var/ftp/pub</span><br><span class="line">[root@pub] mkdir ray</span><br><span class="line">[root@pub] mkdir stone</span><br></pre></td></tr></table></figure>

<p>② 在/etc/vsftpd/目录下新建vusers_dir文件夹，在里面分别新建两个ray,stone命名的文件，在各自的文件中写入相应的权限。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">虚拟用户的存储目录</span></span><br><span class="line">local_root=/var/ftp/pub/raymond</span><br><span class="line">write_enable=yes</span><br><span class="line">anon_umask=022</span><br><span class="line">anon_world_readable_only=no</span><br><span class="line">anon_upload_enable=yes</span><br><span class="line">anon_mkdir_write_enable=yes</span><br><span class="line">anon_other_write_enable=yes</span><br></pre></td></tr></table></figure>

<p>8，配置FTP</p>
<p>①进入vsftpd配置目录下，新建chroot_list文件，将创建的用户ftpuser添加到chroot_list文件中。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">进入到vsftpd配置目录下</span>	</span><br><span class="line">cd /etc/vsftpd</span><br><span class="line"><span class="meta">#</span><span class="bash">新建 chroot_list文件，添加文本内容ftpuser</span></span><br><span class="line">vim chroot_list</span><br><span class="line">1 ftpuser</span><br></pre></td></tr></table></figure>

<p>② 修改vsftpd.conf 文件。</p>
<p>​    添加或修改</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 关闭匿名访问</span></span><br><span class="line">anonymous_enable=NO</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> 禁止系统实体用户登录</span></span><br><span class="line">chroot_local_user=NO</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash">启用限制用户的名单</span></span><br><span class="line">chroot_list_enable=YES</span><br><span class="line"><span class="meta">#</span><span class="bash">指定限制在主目录下的用户名单文件</span></span><br><span class="line">chroot_list_file=/etc/vsftpd/chroot_list</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash">指定根目录</span></span><br><span class="line">local_root=/var/ftp/pub</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash">使用本地时间</span></span><br><span class="line">use_localtime=yes</span><br><span class="line"></span><br><span class="line">pam_service_name=vsftpd.vu</span><br><span class="line"></span><br><span class="line">guest_enable=YES</span><br><span class="line">guest_username=ftpuser</span><br><span class="line">allow_writeable_chroot=YES</span><br><span class="line">user_config_dir=/etc/vsftpd/vusers_dir</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash">开启被动模式（默认是开启的，这里需要指定一个端口范围，不然端口比较随意，不好控制）</span></span><br><span class="line">pasv_enable=YES</span><br><span class="line">pasv_min_port=61001</span><br><span class="line">pasv_max_port=62000</span><br></pre></td></tr></table></figure>

<p>③ 修改selinux ,修改 SELINUX的值为 SELINUX=disable   </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/selinux/config</span><br><span class="line">SELINUX=disable</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash">使selinux=<span class="built_in">disable</span>生效</span></span><br><span class="line">setenforce=0</span><br></pre></td></tr></table></figure>

<p>9 配置防火墙</p>
<p>开发20,21端口，以及61001到62000之间的端口，其中20端口是用来连接的，21端口是用来传输数据的。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">iptables -I INPUT -p tcp --dport 61001:62000 -j ACCEPT</span><br><span class="line">iptables -I OUTPUT -p tcp --sport 61001:62000 -j ACCEPT</span><br><span class="line">iptables -I INPUT -p tcp --dport 20 -j ACCEPT</span><br><span class="line">iptables -I OUTPUT -p tcp --sport 20 -j ACCEPT</span><br><span class="line">iptables -I INPUT -p tcp --dport 21 -j ACCEPT</span><br><span class="line">iptables -I OUTPUT -p tcp --sport 21 -j ACCEPT</span><br></pre></td></tr></table></figure>

<p>10，设置vsftpd开启自启</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl enable vsftpd.service</span><br></pre></td></tr></table></figure>

<p>11 ，验证</p>
<p>重启vsftpd服务</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">重启</span></span><br><span class="line">service vsftpd restart</span><br><span class="line"><span class="meta">#</span><span class="bash">启动</span></span><br><span class="line">service vsftpd start</span><br><span class="line"><span class="meta">#</span><span class="bash">停止</span></span><br><span class="line">service vsftpd stop</span><br><span class="line"><span class="meta">#</span><span class="bash">查看状态</span></span><br><span class="line">service vsftpd status</span><br><span class="line"></span><br></pre></td></tr></table></figure>


      
    </div>

    
    
    
	
	<div>
		
	</div>

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/03/17/JVM/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/03/17/JVM/" class="post-title-link" itemprop="url">JVM</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-03-17 09:20:06" itemprop="dateCreated datePublished" datetime="2022-03-17T09:20:06+08:00">2022-03-17</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2022-03-20 20:08:44" itemprop="dateModified" datetime="2022-03-20T20:08:44+08:00">2022-03-20</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>JVM内存模型的划分：</p>
<h4 id="jdk-jre-jvm是什么关系？？？"><a href="#jdk-jre-jvm是什么关系？？？" class="headerlink" title="jdk, jre ,jvm是什么关系？？？"></a>jdk, jre ,jvm是什么关系？？？</h4><ol>
<li>JRE （java Runtime Environment） java运行环境，所有的java程序都要在jre环境下才能运行。</li>
<li>JDK(java development kit ) 是开发用来编译，调试程序用的开发包。JDK也是java程序，需要在JRE环境上运行。</li>
<li>JVM (java virtual Machine) 是JRE的一部分，是一个虚拟出来的计算机。</li>
</ol>
<h4 id="JVM的内存模型？"><a href="#JVM的内存模型？" class="headerlink" title="JVM的内存模型？"></a>JVM的内存模型？</h4><p>jvm内存模型中有：堆，栈，本地方法栈，程序计数器，方法区。</p>
<p><img src="C:\Users\16406\Desktop\1647483137.jpg" alt="1647483137"></p>
<p>Java堆具有的特点：</p>
<ul>
<li>​    存储的是new出来的对象，不存放基本类型和对象引用。</li>
<li>​    由于创建了大量的对象，垃圾回收器主要工作在堆这块区域。</li>
<li>​         线程共享区域，因此是线程不安全的。</li>
<li>​    能够发生OutOfMemoryError</li>
</ul>
<p>Java虚拟机栈：</p>
<ul>
<li>​    Java虚拟机栈是线程私有的，每一个线程都有独享的一个虚拟机栈，它的生命周期与线程相同。</li>
<li>​    存放基本数据类型（byte，short.，int，char，float ，double，long）和对象的引用。        </li>
</ul>
<p>方法区：</p>
<ul>
<li>​    线程共享区域，因此也是线程不安全的区域。</li>
<li>​    它用于存储已经被虚拟机加载的类信息，常量，静态变量等。</li>
<li>​    当方法区无法满足内存分配时，将抛出OutOfMemoryError异常。</li>
</ul>
<p>程序计数器：</p>
<ul>
<li>​    程序计数器的作用是记录当前线程所执行的位置，当线程重新获取cpu执行时，就能直接从记录的位置开始执行。    </li>
</ul>
<blockquote>
<p>(注* 内容引自 <a target="_blank" rel="noopener" href="https://mp.weixin.qq.com/s/nSwNZpObWLGteG-v7n5PSw">https://mp.weixin.qq.com/s/nSwNZpObWLGteG-v7n5PSw</a>)</p>
</blockquote>

      
    </div>

    
    
    
	
	<div>
		
	</div>

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/01/20/Redis/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/01/20/Redis/" class="post-title-link" itemprop="url">Redis</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-01-20 22:31:24" itemprop="dateCreated datePublished" datetime="2022-01-20T22:31:24+08:00">2022-01-20</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2022-01-28 22:54:28" itemprop="dateModified" datetime="2022-01-28T22:54:28+08:00">2022-01-28</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Redis/" itemprop="url" rel="index"><span itemprop="name">Redis</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>Redis是什么？</p>
<h4 id="1，项目中如何使用缓存？为什么要使用缓存？缓存使用不当有什么坏处？"><a href="#1，项目中如何使用缓存？为什么要使用缓存？缓存使用不当有什么坏处？" class="headerlink" title="1，项目中如何使用缓存？为什么要使用缓存？缓存使用不当有什么坏处？"></a>1，<strong>项目中如何使用缓存？为什么要使用缓存？缓存使用不当有什么坏处？</strong></h4><p>​    <strong>为什么要用缓存（好处）：</strong>用缓存，高性能，高并发。</p>
<p><strong>高性能场景：</strong>一个请求，大数据量，数据不经常更改，一次查询数据库耗时太长，可以再第一次查之后将数据进行缓存redis中，下次请求时直接从redis中获取，避免多次查询数据库。</p>
<p><strong>高并发场景：</strong>假如在请求高峰期，一秒内有1万个请求，直接查mqsql数据库，数据库会死掉，此时可以把数据放到缓存中，缓存单机支撑并发量一秒有几万甚至十几万，支撑高并发。</p>
<p><strong>缓存是走内存的，内存天然就支撑高并发</strong>。</p>
<p><strong>项目里哪个模块用到了缓存？为啥要用？用了之后可能会产生什么问题？</strong>（需要根据自己实际项目进行思考）</p>
<h4 id="2，用来缓存之后可能会有的不良后果（坏处）？"><a href="#2，用来缓存之后可能会有的不良后果（坏处）？" class="headerlink" title="2，用来缓存之后可能会有的不良后果（坏处）？"></a><strong>2，用来缓存之后可能会有的不良后果（坏处）？</strong></h4><ul>
<li><p>缓存与数据库双写不一致。</p>
</li>
<li><p>缓存雪崩，缓存击穿，缓存穿透。</p>
<p>​    客户端发起请求，从缓存中获取数据，如果缓存中没有，则从数据库中查询出数据，更新到缓存中进行存储，并正确返回。</p>
<p>​    <img src="https://gitee.com/wqqszz/blogImg/raw/master/img/image-20220128213258548.png" alt="image-20220128213258548" style="zoom: 67%;" /></p>
<p><strong>缓存雪崩：</strong></p>
<p>​        缓存雪崩是指缓存中大批量的数据到了过期时间，而查询数据量巨大，引起数据库压力过大甚至宕机。和缓存击穿不同的是，缓存击穿指并发查同一条记录，缓存雪崩是不同数据都过期了，很多数据都查不到而从数据库中查。</p>
<p>​        解决方案：1.缓存数据的过期时间设置随机，防止同一时间大量数据出现过期现象。</p>
<p>​                        2.设置热点数据永远不过期。</p>
<p>​                        3，如果缓存数据库是分布式部署的，将热点数据均匀的分布。</p>
<p><strong>缓存击穿</strong>：</p>
<p>​        缓存击穿是指缓存中没有数据，但是数据库中有数据（一般是由缓存到期引起），这时由于<strong>并发用户特别多</strong>，同时读缓存没有读取到数据，又同时去数据库中取数据，引起数据库压力瞬间增大，造成压力过大</p>
<p>​        解决方案：设置热点数据永远不过期：</p>
<p>​                        接口限流与熔断，降级：</p>
<p>​                            布隆过滤器：</p>
<p>​                        加互斥 锁：</p>
<p><strong>缓存穿透：</strong></p>
<p>​    缓存穿透是指<strong>缓存和数据库中都没有的数据</strong>，而用户不断发起请求。由于缓存是不命中时被动写的，并且出于容错考虑，如果从存储层查不到数据则不写入缓存，这将导致这个不存在的数据每次请求都要到存储层去查询，失去了缓存的意义。</p>
<p>在流量大时，可能DB就挂掉了，要是有人利用不存在的key频繁攻击我们的应用，这就是漏洞。</p>
<p>如发起为id为“-1”的数据或id为特别大不存在的数据。这时的用户很可能是攻击者，攻击会导致数据库压力过大。</p>
</li>
<li><p>缓存并发竞争</p>
</li>
</ul>
<h4 id="3-Redis的都有哪些数据类型？分别在哪些场景下使用比价合适？"><a href="#3-Redis的都有哪些数据类型？分别在哪些场景下使用比价合适？" class="headerlink" title="3 Redis的都有哪些数据类型？分别在哪些场景下使用比价合适？"></a><strong>3 Redis的都有哪些数据类型？分别在哪些场景下使用比价合适？</strong></h4><ul>
<li>Strings,  最简单的数据类型，做简单的 KV缓存， </li>
<li>Hashes,  这个类似于 map的一种结构，可以将结构化的数据比如对象（前提是该对象中不能包括其他对象）给缓存到redis中。</li>
<li>Lists , 有序列表，可以通过list存储一些列表型的数据结构，可以通过lrange命令，读取某个闭区间内的元素，可以通过list实现分页查询。</li>
<li>Sets,  无序集合，自动去重。可以基于set实现交集，并集，差集操作。</li>
<li>Sorted Sets    ，是排序的Set，去重但可以排序，可以实现自动排序。</li>
<li>Redis除了这5中基本类型，还有Bitmaps， HyperLogLogs, Streams 等。</li>
</ul>
<p><strong>4.Redis的过期策略都有哪些？内存淘汰机制有哪些？</strong></p>
<p> 在生产环境的Redis经常会丢失一些数据，写进去了 ，但是过一段时间就没有了？？？这是为什么？？？这是由Redis的过期策略来决定的。</p>
<p>Redis的过期策略是：定期删除+惰性删除</p>
<p>定期删除：指的是Redis默认每隔100ms就会随抽取一些设置了过期时间的key，检查是否已经过期，如果过期就删除。（定期删除可能会导致很多到了过期时间的key没有被删除。）</p>
<p>惰性删除：就是你获取某个key时，Redis会检查这个key是否设置了过期时间，如果设置了且已经过期，就会删除改key,不返回你任何东西。</p>
<p>如果定期删除遗漏掉了过期的key,  且你也没有及时查找，导致没有走惰性删除，此时就需要走内存淘汰机制。</p>
<h4 id="5-内存淘汰机制"><a href="#5-内存淘汰机制" class="headerlink" title="5.内存淘汰机制"></a>5.内存淘汰机制</h4><p>Redis的内存淘汰机制有如下：</p>
<p>noeviction: 当内存不足以容纳新写入的数据时，此时写入会报错（一般不用）。</p>
<p>allkeys-lru: 当内存不足以容纳新写入的数据时，会删除最近最少使用到的key(最常用的)。</p>
<p>allkeys-random:当内存不足以容纳新写入的数据时，会随机删除某个key,(一般不用)。</p>
<p>volatile-lru: 当内存不足以容纳新写入的数据时,在设置了过期时间的键空间中，删除最近最少用的key。</p>
<p>volatile-random:当内存不足以容纳新写入的数据时,在设置了过期时间的键空间中，随机删除某个key.</p>
<p>volatile-ttl: 当内存不足以容纳新写入的数据时,在设置了过期时间的键空间中，有更早过期时间的key优先删除。</p>
<h4 id="6-Redis的高并发，高可用？Redis的主从复制？Redis的哨兵原理？"><a href="#6-Redis的高并发，高可用？Redis的主从复制？Redis的哨兵原理？" class="headerlink" title="6.Redis的高并发，高可用？Redis的主从复制？Redis的哨兵原理？"></a>6.Redis的高并发，高可用？Redis的主从复制？Redis的哨兵原理？</h4>
      
    </div>

    
    
    
	
	<div>
		
	</div>

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/12/05/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/12/05/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/" class="post-title-link" itemprop="url">开发工具</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>
      

      <time title="创建时间：2021-12-05 11:58:14 / 修改时间：12:35:06" itemprop="dateCreated datePublished" datetime="2021-12-05T11:58:14+08:00">2021-12-05</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7s/" itemprop="url" rel="index"><span itemprop="name">开发工具s</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h2 id="Idea："><a href="#Idea：" class="headerlink" title="Idea："></a>Idea：</h2><h4 id="idea下载官网地址："><a href="#idea下载官网地址：" class="headerlink" title="idea下载官网地址："></a>idea下载官网地址：</h4><p>​                <a target="_blank" rel="noopener" href="https://www.jetbrains.com/idea/download/#section=windows">https://www.jetbrains.com/idea/download/#section=windows</a></p>
<h4 id="idea下载网盘地址："><a href="#idea下载网盘地址：" class="headerlink" title="idea下载网盘地址："></a>idea下载网盘地址：</h4><p>​                链接：<a target="_blank" rel="noopener" href="https://pan.baidu.com/s/1xjLAUqFRVCCVigtyNwnYyQ">https://pan.baidu.com/s/1xjLAUqFRVCCVigtyNwnYyQ</a><br>​                                    提取码：3ubz</p>
<h4 id="idea-破解流程：破解补丁："><a href="#idea-破解流程：破解补丁：" class="headerlink" title="idea 破解流程：破解补丁："></a>idea 破解流程：破解补丁：</h4><p>​                链接：<a target="_blank" rel="noopener" href="https://pan.baidu.com/s/1gbOwQzpyzn1OH3-i5K_-WA">https://pan.baidu.com/s/1gbOwQzpyzn1OH3-i5K_-WA</a><br>​                                    提取码：n17k</p>
<h4 id="破解流程："><a href="#破解流程：" class="headerlink" title="破解流程："></a>破解流程：</h4><ol>
<li><p>​                下载破解补丁，把 FineAgent.jar 补丁放到ided安装目录的bin文件夹下（或自己指定的任意目录）。</p>
</li>
<li><p>​                打开idea ,  help  –&gt; Edit custom VM Options 修改 idea64.exe.vmoptions 文件，在文件末尾追加  FineAgent.jar 的绝对路径。</p>
</li>
<li><p>​                重启 idea </p>
</li>
<li><p>​                help –&gt; register  选择Activation Code  输入激活码（补丁包里ActivationCode.txt） ，点击 Ok 激活完成。</p>
</li>
<li><p>​                查看激活到期时间：help —&gt; about 中间位置可以看到激活到期期限。</p>
<p>（    备注：破解方法来源于原文：  <a target="_blank" rel="noopener" href="https://istio.tech/posts/2375004886/">https://istio.tech/posts/2375004886/</a>                    ）</p>
</li>
</ol>
<p>​                </p>

      
    </div>

    
    
    
	
	<div>
		
	</div>

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/12/05/hexo%E8%AF%AD%E6%B3%95/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/12/05/hexo%E8%AF%AD%E6%B3%95/" class="post-title-link" itemprop="url">Hexo语法</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>
      

      <time title="创建时间：2021-12-05 11:40:35 / 修改时间：15:29:29" itemprop="dateCreated datePublished" datetime="2021-12-05T11:40:35+08:00">2021-12-05</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Hexo%E8%AF%AD%E6%B3%95/" itemprop="url" rel="index"><span itemprop="name">Hexo语法</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h3 id="cmd-或者-git-bash-执行hexo-命令："><a href="#cmd-或者-git-bash-执行hexo-命令：" class="headerlink" title="cmd 或者 git bash 执行hexo 命令："></a>cmd 或者 git bash 执行hexo 命令：</h3><ol>
<li>进入 D:/myblog 进入项目文件</li>
<li>创建新页面  hexo new page “新文件夹名” ，文件夹里有对应的index.md文件</li>
<li> hexo new “新文件名” ，新创建的文件会在 _posts文件夹里</li>
<li>通过 Typora  编写 新文件内容 </li>
<li>本地运行myblog项目，hexo  s</li>
<li>发布到gitee  命令 hexo  d  -g  </li>
</ol>

      
    </div>

    
    
    
	
	<div>
		
	</div>

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/12/05/%E6%A8%A1%E5%BC%8F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/12/05/%E6%A8%A1%E5%BC%8F/" class="post-title-link" itemprop="url">设计模式</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-12-05 11:38:38" itemprop="dateCreated datePublished" datetime="2021-12-05T11:38:38+08:00">2021-12-05</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-12-27 21:46:18" itemprop="dateModified" datetime="2021-12-27T21:46:18+08:00">2021-12-27</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h2 id="设计模式"><a href="#设计模式" class="headerlink" title="设计模式"></a>设计模式</h2><h3 id="1-定义"><a href="#1-定义" class="headerlink" title="1. 定义"></a>1. 定义</h3><p>Java包含23种设计模式，是一套对代码设计经验的总结，被人们反复利用，多人熟知的代码设计方式。</p>
<h3 id="2-设计模式的分类"><a href="#2-设计模式的分类" class="headerlink" title="2. 设计模式的分类"></a>2. 设计模式的分类</h3><p><img src="https://gitee.com/wqqszz/blogImg/raw/master/img/1639230964(1).png" alt="1639230964(1)"></p>
<h3 id="3-栗子"><a href="#3-栗子" class="headerlink" title="3. 栗子"></a>3. 栗子</h3><h4 id="单例模式：程序从始至终只创建一个对象。（私有构造，静态方法）"><a href="#单例模式：程序从始至终只创建一个对象。（私有构造，静态方法）" class="headerlink" title="单例模式：程序从始至终只创建一个对象。（私有构造，静态方法）"></a>单例模式：程序从始至终只创建一个对象。（私有构造，静态方法）</h4><p>​    懒汉式：    </p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 懒汉式单例模式，用时创建变量，不用时不创建</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SingleTonDemo</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 私有静态变量</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> User user=<span class="keyword">null</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 私有构造</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">SingleTonDemo</span><span class="params">()</span></span>&#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 静态方法</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> User <span class="title">getInstance</span><span class="params">()</span></span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(user == <span class="keyword">null</span>)&#123;</span><br><span class="line">            user=<span class="keyword">new</span> User();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> user;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>​    饿汉式：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 饿汉式单例模式，直接创建变量，不管用或不用</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SingleTonDemo2</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 私有静态变量</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> User user =<span class="keyword">new</span> User();</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 私有构造</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">SingleTonDemo2</span><span class="params">()</span></span>&#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 对外提供静态方法</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> User <span class="title">getInstance</span><span class="params">()</span></span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(user != <span class="keyword">null</span>)&#123;</span><br><span class="line">            <span class="keyword">return</span> user;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">null</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2021/12/05/%E6%A8%A1%E5%BC%8F/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
	
	<div>
		
	</div>

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/11/04/%E6%A1%86%E6%9E%B6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/11/04/%E6%A1%86%E6%9E%B6/" class="post-title-link" itemprop="url">框架</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-11-04 22:51:17" itemprop="dateCreated datePublished" datetime="2021-11-04T22:51:17+08:00">2021-11-04</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2022-03-26 17:31:47" itemprop="dateModified" datetime="2022-03-26T17:31:47+08:00">2022-03-26</time>
      </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h3 id="Spring-框架："><a href="#Spring-框架：" class="headerlink" title="Spring 框架："></a>Spring 框架：</h3><h4 id="1，简述一下你对Spring框架的了解？"><a href="#1，简述一下你对Spring框架的了解？" class="headerlink" title="1，简述一下你对Spring框架的了解？"></a>1，简述一下你对Spring框架的了解？</h4><p>spring框架是一个轻量级的框架，能够简化代码的开发，</p>
<p>Spring框架的优点有：</p>
<p>IOC控制反转，就是以前创建对象由开发人员自己进行创建维护的，使用了Spring后对象的创建维护全部由spring容器完成创建以及注入。    </p>
<p>DI依赖注入：注入多个对象之间的依赖关系。</p>
<p>依赖注入的方式有：set方式注入，构造方法注入，字段注入，</p>
<p>注入类型：值类型注入，引用类型注入。</p>
<p>注解：@Autowired，@Resource 都能实现注入，@Autowired是spring框架带的，@Resource是java自身带的注解</p>
<h4 id="2，SpringBoot自动装配？"><a href="#2，SpringBoot自动装配？" class="headerlink" title="2，SpringBoot自动装配？"></a>2，SpringBoot自动装配？</h4><p><a target="_blank" rel="noopener" href="https://baijiahao.baidu.com/s?id=1725265949551075777&amp;wfr=spider&amp;for=pc">https://baijiahao.baidu.com/s?id=1725265949551075777&amp;wfr=spider&amp;for=pc</a></p>

      
    </div>

    
    
    
	
	<div>
		
	</div>

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/08/24/interview/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/08/24/interview/" class="post-title-link" itemprop="url">面试题</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-08-24 21:22:38" itemprop="dateCreated datePublished" datetime="2021-08-24T21:22:38+08:00">2021-08-24</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2022-03-15 15:09:53" itemprop="dateModified" datetime="2022-03-15T15:09:53+08:00">2022-03-15</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <ol>
<li><h4 id="聊聊spring？谈谈Spring-IOC的理解，原理与实现？"><a href="#聊聊spring？谈谈Spring-IOC的理解，原理与实现？" class="headerlink" title="聊聊spring？谈谈Spring IOC的理解，原理与实现？"></a>聊聊spring？谈谈Spring IOC的理解，原理与实现？</h4><p>总：</p>
<p>IOC:控制反转，原来的对象是由使用者控制创建的，有了spring后，可以把整个对象交给Spring 来帮我们信息管理创建；</p>
<p>DI：依赖注入，把对应的属性的值注入到具体的对象中，@Autowired ,populateBean 完成属性值的注入；</p>
<p><strong>spring容器：存储对象，使用map对象存储</strong>，在spring中一般存在三级缓存，singletonObject 存放完整的bean对象，整个bean的生命周期，<strong>从bean的创建到bean的使用到bean的销毁都是由spring容器管理的。</strong></p>
<p>分：</p>
<p>①，一般聊ioc容器的时候要涉及到容器的创建过程：ioc容器创建的时候，有一个最上层的根接口 beanFactory,没有提供对应的子类实现，DefaultListableBeanFactory,（）</p>
<p>AOP: 面向切面编程，动态代理实现（动态代理有两种：jdk，cglib）</p>
</li>
</ol>
<p>   扩展：什么是三级缓存？bean生命周期？还有其他的map类型吗？</p>
<ol start="2">
<li><h4 id="说说bean的生命周期？"><a href="#说说bean的生命周期？" class="headerlink" title="说说bean的生命周期？"></a>说说bean的生命周期？</h4><p><img src="https://gitee.com/wqqszz/blogImg/raw/master/img/bean.jpg"></p>
<p><strong>①：实例化bean:</strong> 反射的方式生成对象；（可以引来反射一系列问题）</p>
<p><strong>②：填充bean属性：</strong>关键的方法 populateBean(),循环依赖的问题（三级缓存）；</p>
<p><strong>③：调用Aware相关接口的方法：</strong>invokeAwareMethod（完成BeanName,BeanFactory,BeanClassLoader对象的属性设置）；</p>
<p><strong>④：调用BeanPostProcessor中的前置处理方法</strong>：使用比较多的有（ApplicationContextPostProcessor 设置ApplicationContext, Environment 等对象）；</p>
<p><strong>⑤：调用initmethod方法：</strong>invokeinitmethod()， 判断是否实现了initializingBean接口，如果有，调用afterPropertiesSet方法，没有就不调用；</p>
<p><strong>⑥：调用 BeanPostProcessor 的后置处理方法：</strong>spring的aop就是在此处实现的；</p>
<p><strong>⑦：获取完整的对象</strong>，可以通过getBean的方式来进行对象的获取；</p>
<p><strong>⑧：销毁</strong>：判断是否实现了DispoableBean接口；调用DestoryMethod方法；</p>
</li>
<li><h4 id="Spring-Bean的循环依赖？"><a href="#Spring-Bean的循环依赖？" class="headerlink" title="Spring Bean的循环依赖？"></a>Spring Bean的循环依赖？</h4><p>什么是循环依赖：  </p>
<p>​        类A通过构造函数注入类B的的实例中，而类Bt通过构造函数注入类A中，即将类A和类B的bean配置为相互注入。</p>
<p><img src="C:\Users\16406\Desktop\1647326853(1).png" alt="1647326853(1)"></p>
<p>如何解决SpringBean的循环依赖问题：</p>
<p>​     解决的方法：就是不使用基于构造函数的依赖注入，可以通过如下两种方法：</p>
<p>​    ①，在实例变量上加上@Autowired注解，让Spring自行在合适的时机注入，而非初始化类的时候就注入。</p>
<p>​    ②，用基于setter方法的依赖注入取代基于构造函数的依赖注入。</p>
<p>​    解决循环依赖机制：根据Spring框架内定义的<strong>三级缓存来实现的</strong>，（前提是：bean是单例的）（Spring默认的bean是单例的，对于单例的Bean之间的循环依赖问题，Spring是可以通过三级缓存进行解决的。）</p>
<p>​</p>
</li>
<li><h4 id="三级缓存"><a href="#三级缓存" class="headerlink" title="三级缓存"></a>三级缓存</h4><p>singletonObjects : 一级缓存，里面放置的是实例化好的单例对象。</p>
<p>earlySingletonObjects: 二级缓存，里面存放的是提前曝光的单例对象。</p>
<p>singletonFactories: 三级缓存，里面存放的是要被实例化的对象的对象工厂。</p>
<p>​</p>
<p>​</p>
</li>
<li><h4 id="FactoryBean-和BeanFactory区别："><a href="#FactoryBean-和BeanFactory区别：" class="headerlink" title="FactoryBean 和BeanFactory区别："></a>FactoryBean 和BeanFactory区别：</h4><p>BeanFactory 和 FactoryBean 其实没有什么可以比较的，只是名字相近，所以有时候会拿出来进行比较，BeanFactory 是提供了IOC容器最基本的形式，给具体的 IOC 容器的实现提供了规范，</p>
<p>FactoryBean 在 IOC 容器的基础上给 Bean的实现加上了一个简单工厂模式和装饰模式，我们可以在 getObject() 方法中灵活配置，其实在spring 源码中有很多FactoryBean 的实现类，想要深入准确的理解 FactoryBean ，只能读取Spring 源码了。。。。。</p>
</li>
</ol>
<ol start="6">
<li><h4 id="ApplicationContext-和-BeanFactory的区别"><a href="#ApplicationContext-和-BeanFactory的区别" class="headerlink" title="ApplicationContext 和 BeanFactory的区别"></a>ApplicationContext 和 BeanFactory的区别</h4><p>​</p>
</li>
<li><h4 id="设计模式"><a href="#设计模式" class="headerlink" title="设计模式"></a>设计模式<img src="https://gitee.com/wqqszz/blogImg/raw/master/img/image-20210828215610486.png" alt="image-20210828215610486"></h4></li>
<li><h4 id="SpringMVC-框架？"><a href="#SpringMVC-框架？" class="headerlink" title="SpringMVC 框架？"></a>SpringMVC 框架？</h4><h4 id="SpringMvc原理流程："><a href="#SpringMvc原理流程：" class="headerlink" title="SpringMvc原理流程："></a>SpringMvc原理流程：</h4></li>
</ol>
<p><img src="https://gitee.com/wqqszz/blogImg/raw/master/img/%E6%8D%95%E8%8E%B7.PNG" alt="捕获"></p>

      
    </div>

    
    
    
	
	<div>
		
	</div>

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/08/13/docker/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/08/13/docker/" class="post-title-link" itemprop="url">Docker</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-08-13 15:15:00" itemprop="dateCreated datePublished" datetime="2021-08-13T15:15:00+08:00">2021-08-13</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-11-04 22:51:43" itemprop="dateModified" datetime="2021-11-04T22:51:43+08:00">2021-11-04</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Docker/" itemprop="url" rel="index"><span itemprop="name">Docker</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>[TOC]</p>
<h3 id="Docker-三要素"><a href="#Docker-三要素" class="headerlink" title="Docker 三要素"></a>Docker 三要素</h3><ol>
<li><p>仓库</p>
</li>
<li><p>镜像</p>
</li>
<li><p>容器：有镜像才能创建容器</p>
</li>
</ol>
<h3 id="Docker-容器命令"><a href="#Docker-容器命令" class="headerlink" title="Docker 容器命令"></a>Docker 容器命令</h3><ol>
<li><table>
<thead>
<tr>
<th>docker常用命令</th>
<th>说明</th>
<th>栗子</th>
</tr>
</thead>
<tbody><tr>
<td>docker run [options] image [command] [arg]</td>
<td>新建并启动容器，参数：-i 以交互模式云信容器，通常与 -t 一起使用，-t 为容器分配一个伪输入终端 ，– name 为启动容器指定名字，否则系统随机分配 ，-d 后台进行启动运行</td>
<td>docker run -it centos  / docker run -d  centos</td>
</tr>
<tr>
<td>docker run -it -p 8888:8080 tomcat</td>
<td>docker run -it -p 指定端口:软件端口  tomcat        (-p指定端口)                                             docker run -it -P 随机生成端口：软件端口 tomcat （-P随机生成端口）</td>
<td></td>
</tr>
<tr>
<td>docker ps  [options]</td>
<td>查看当前docker下所有运行的容器 ，默认查看当前正在运行的镜像，参数：-a 正在运行的和历史上运行的镜像, -n 3 查看最近启动的前三个镜像</td>
<td>docker ps -a    /  docker ps -n 3</td>
</tr>
<tr>
<td>exit</td>
<td>退出并停止当前容器</td>
<td>exit</td>
</tr>
<tr>
<td>ctrl+Q+P 快捷键</td>
<td>退出但是不停止当前容器</td>
<td>按住ctrl+Q+P</td>
</tr>
<tr>
<td>docker start [容器id]</td>
<td>启动已经退出的容器,启动成功后返回对应的容器id</td>
<td>docker start  fcavde011</td>
</tr>
<tr>
<td>docker stop [容器id]</td>
<td>关掉容器</td>
<td></td>
</tr>
<tr>
<td>docker kill  [容器id]</td>
<td>强制停止容器</td>
<td></td>
</tr>
<tr>
<td>docker rm [容器id]</td>
<td>删除容器 ，-f 强制删除</td>
<td></td>
</tr>
<tr>
<td>docker attach [容器id]</td>
<td>重新进入退出但是没有停止的容器</td>
<td></td>
</tr>
<tr>
<td>docker exec -t [容器id]  [操作命令]</td>
<td>不进入容器，但是执行结果与在容器内执行结果一样，（隔山打牛）</td>
<td>docker exec -t 01sacee10  ls -l /temp</td>
</tr>
<tr>
<td>docker cp [容器id:拷贝文件路径文件]   [目标路径]</td>
<td>从容器中拷贝文件到宿主机</td>
<td></td>
</tr>
</tbody></table>
</li>
</ol>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2021/08/13/docker/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
	
	<div>
		
	</div>

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/08/01/Linux/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2021/08/01/Linux/" class="post-title-link" itemprop="url">Linux</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-08-01 17:19:17" itemprop="dateCreated datePublished" datetime="2021-08-01T17:19:17+08:00">2021-08-01</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-08-22 13:41:25" itemprop="dateModified" datetime="2021-08-22T13:41:25+08:00">2021-08-22</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h2 id="Linux-常用命令"><a href="#Linux-常用命令" class="headerlink" title="Linux 常用命令"></a>Linux 常用命令</h2><h3 id="文件操作命令"><a href="#文件操作命令" class="headerlink" title="文件操作命令"></a>文件操作命令</h3><h6 id="mkdir命令"><a href="#mkdir命令" class="headerlink" title="mkdir命令"></a>mkdir命令</h6><table>
<thead>
<tr>
<th>功能简介：创建文件夹</th>
</tr>
</thead>
<tbody><tr>
<td>常用组合：</td>
</tr>
<tr>
<td>mkdir   test   #创建一级文件夹test</td>
</tr>
<tr>
<td>mkdir -p  test/test1/test2  #创建多级目录</td>
</tr>
</tbody></table>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2021/08/01/Linux/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
	
	<div>
		
	</div>

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>

</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">WQQ</span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>

  




  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>





<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
